<?php
class MY_Config extends CI_Config {

/**
* CodeIgniter Config Extended Library
*
* This class extends the config to a database
*
* @package        CodeIgniter
* @subpackage    Extended Libraries
* @category    Extended Libraries
* @author        Tim Wood (aka codearachnid)
* @link        http://www.codearachnid.com/ci/db_fetch
*
* you must have the following structure setup in order to use this class
*
    CREATE TABLE IF NOT EXISTS `site_config` (
      `config_id` int(11) NOT NULL auto_increment,
      `last_updated` timestamp NOT NULL default '0000-00-00 00:00:00' on update CURRENT_TIMESTAMP,
      `config_key` varchar(60) NOT NULL,
      `config_value` longtext NOT NULL,
      PRIMARY KEY  (`config_id`)
    ) ENGINE=MyISAM;
*
*
*/
	function  __construct()  {
		parent::__construct();
    }	
    
    function db_config_fetch()
    {
        $CI =& get_instance();
        $query = $CI->db->get($this->item('dbt_site_config'));
        
        foreach ($query->result() as $row)
        {
            $this->set_item($row->config_key, $row->config_value);
        }
        
    }
	
    function site_url($uri = '')
    {    
        if (is_array($uri))
        {
            $uri = implode('/', $uri);
        }
        
        if (function_exists('get_instance'))        
        {
            $CI =& get_instance();
            $uri = $CI->lang->localized($uri);            
        }

        return parent::site_url($uri);
    }	
    
}
?>